/*
** sum_params.c for sum_params in /home/goupil_r//afs/Jour_08
** 
** Made by robin goupil
** Login   <goupil_r@epitech.net>
** 
** Started on  Wed Oct 10 11:05:12 2012 robin goupil
** Last update Thu Oct 11 10:33:24 2012 robin goupil
*/

#include <stdlib.h>

int	get_size(int ac, char **av)
{
  int	i;
  int	size_t;

  i = 0;
  size_t = ac;
  while (i < ac)
    {
      size_t = size_t + my_strlen(av[i]);
      i = i + 1;
    }
  return size_t;
}

void	add_bn(int *j, int *k, int ac, char *out)
{
  if (*j < ac - 1)
    {
      out[*k] = '\n';
      *k = *k + 1;
    }
}

char	*sum_params(int ac, char **av)
{
  int	i;
  int	j;
  int	k;
  int	size_t;
  char	*out;

  size_t = get_size(ac, av);
  i = 0;
  j = 0;
  k = 0;
  out = malloc(size_t * sizeof(char));
  while (j < ac)
    {
      while (i < my_strlen(av[j]))
	{
	  out[k] = av[j][i];
	  i = i + 1;
	  k = k + 1;
	}
      add_bn(&j, &k, ac, out);
      i = 0;
      j = j + 1;
    }
  return (out);
}
